package com.duing.util;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

public class JsoupUtil {
    public static void main(String[] args) {
//        String html = "<html><body><p>Hello, Jsoup!</p></body></html>";
//        Document doc = Jsoup.parse(html);
//        String text = doc.body().text();
//        System.out.println(text);
        try {
            Document doc = Jsoup.connect("https://zhuanlan.zhihu.com").get();
//            String title = doc.title();
//            System.out.println("title :" + title);

//            Elements links = doc.getElementsByTag("a");
//            for (Element link : links) {
//                System.out.println(link.attr("href") + " | " + link.text());
//            }
            Elements elements = doc.getElementsByTag("script");
            System.out.println("elements size: " + elements.size() + "; elements :" + elements.toString());

        }catch (Exception e){
            System.out.println("error" + e.getMessage());
        }
    }
}
